# sort
# reverse
import random

numbers = []
for i in range(8):
    ran = random.randint(1,100)
    numbers.append(ran)
print(numbers)

numbers.reverse() # 翻转
print(numbers)

numbers.sort() # 从小到大,默认是升序,False
print(numbers)

numbers.sort(reverse=True) # 从大到小,降序,True
print(numbers)

'''
输入一个1-100之间的整数,将整数插入到排序后的列表中[1,9,6 8,0]
'''
# num = [1,9,6,8,0]
# ran = int(input('请输入一个数:'))
# num.append(ran)
# num.sort()
# print(num)
print('-----------------------')
# 冒泡排序
nums = [32, 12, 45, 67, 89, 23, 45, 56, 78, 90]
for i in range(len(nums)):
    for j in range(len(nums)-1):
        if nums[j] > nums[j + 1]:
            a = nums[j]
            nums[j] = nums[j + 1]
            nums[j + 1] = a
print(nums)

for i in range(len(nums)):
    for j in range(len(nums)-1):
        if nums[j] > nums[j+1]:
            nums[j], nums[j+1] = nums[j+1], nums[j]
print(nums)
